﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="ZX.Web.UI.Controls.miniDataGrid" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="/SFramework/boot.js"></script>
    <link href="/SFramework/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <style type="text/css">
        body {
            padding-left: 0px;
            font-size: 13px;
        }

        h1 {
            font-size: 20px;
            font-family: Verdana;
        }

        h4 {
            font-size: 16px;
            margin-top: 25px;
            margin-bottom: 10px;
        }

        .description {
            padding-bottom: 30px;
            font-family: Verdana;
        }

        .description h3 {
            color: #CC0000;
            font-size: 16px;
            margin: 0 30px 10px 0px;
            padding: 45px 0 8px;
            /*background:url(titleback.png) no-repeat scroll left bottom transparent*/
            border-bottom: solid 1px #888;
        }

        body {
            margin: 0;
            padding: 0;
            border: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }
    </style>

    <!--引入皮肤样式-->
    <%--    <link href="/SFramework/miniui/themes/blue/skin.css" rel="stylesheet" />--%>
</head>

<body>

    <div class="mini-splitter" style="width: 100%; height: 100%;">
        <div size="240" showcollapsebutton="true">
            <div class="mini-toolbar" style="padding: 2px; border-top: 0; border-left: 0; border-right: 0;">
                <% =getItem("left") ==""?"组织结构":getItem("left") %>
            </div>
            <div class="mini-fit">
                <ul class="ztree" id="tree1"url="/extendpage/data/jsondata.aspx?entity=<%=GetStringFromQueryString("masterentity","t_base_department") %>&condition=<% =GetStringFromQueryString("master_condition","") %>&type=1" style="width: 100%;"
                    showtreeicon="true" textfield="name" idfield="id" parentfield="parent_id" resultastree="false" expandonload="true">
                </ul>
            </div>
        </div>
        <div showcollapsebutton="true">
            <div class="mini-toolbar" style="padding: 2px; border-top: 0; border-left: 0; border-right: 0;">
                  <table style="width: 100%;">
                    <tr>
                        <td style="width: 100%;">
                             <%=getItem("") %>
                        </td>
                        <td style="white-space: nowrap;">
                            <input type="checkbox" id="checkAndOr" /><span style="margin-top: -5px;">并集</span>
                            <input id="QueryContext" type="text" />
                            <a class="mini-button" onclick="fnQuciklyQuery()">查询</a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="mini-fit">
                <div id="grid1" class="mini-datagrid" style="width: 100%; height: 100%;"
                    borderstyle="border:0;" allowcelledit="<%=AllowEdit.ToString().ToLower() %>"
                    url="../data/jsondata.aspx?entity=<%=EntityName%>&order=<%=Order==""?"sort":Order%>&type=1"
                    allowcellselect="true" allowcelledit="<%=AllowEdit.ToString().ToLower()%>">
                    <div property="columns">
                        <%=DataFields %>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/SFramework/ztree/js/jquery.ztree.all-3.3.min.js"></script>
    <script type="text/javascript">
        const_entityID = "<% =EntityId %>",    //实体ID名称
        const_entityName = "<% =EntityName %>",//实体名称
        const_EditEntity = "<% =EditEntity %>",//编辑实体名
        const_functionId   ="<% =FunctionID %>",//自定义条件
        const_Order ="<% =Order %>",           //排序  
        const_UserId = "<% = UserId %>",       // 
        const_QueryField="<% =QuciklyQueryFields %>",
        const_CustomCondition = encodeURI("<% =DefineCondition %>"),//查询方案条件
        const_Condition = encodeURI("<% =Condition %>"),//
        const_PageTitle=encodeURI("<% =PageTitle %>"),
        _openWindowHeight=<%=EditWindowHeight%>,
        _openWindowWidth=<%=EditWindowWidth%>;
        <% =ColumnDataSource%>
    </script>
    <script>
        <% =List_self_script %>
    </script>
    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("grid1");
        /* 树 */
        var setting = { 
            edit: {
                drag: {
                    autoExpandTrigger: true,
                    prev: dropPrev,
                    inner: dropInner,
                    next: dropNext
                },
                enable: true,
                showRemoveBtn: false,
                showRenameBtn: false,
                editNameSelectAll: false

            },
            data: {
                key: {
                    title: "t"
                },
                simpleData: {
                    enable: true,
                    idKey:"id",
                    pIdKey:"parent_id"
                }
            },
            callback: {
                beforeClick: beforeClick,
                onClick: onClick,
                beforeDrag: beforeDrag,
                beforeDrop: beforeDrop,
                beforeDragOpen: beforeDragOpen,
                onDrag: onDrag,
                onDrop: onDrop,
                onExpand: onExpand
            }
        };


        var log, className = "dark";
        function beforeClick(treeId, treeNode, clickFlag) {
            className = (className === "dark" ? "" : "dark");
            return (treeNode.click != false);
        }

        var _treeNode = null;
        function onClick(event, treeId, treeNode, clickFlag) {
            var id = treeNode.id;
            _treeNode = treeNode;

            treeId=e.node.id;
            grid.setUrl("../data/jsondata.aspx?entity=" + const_entityName +  "&order" + const_Order + "&datagrid=true&pagesize=1000&customCondition=<%=Condition %>&condition=<%=GetStringFromQueryString("fkey","parent_id")%>='"+treeId+"'");
            grid.load({});
        }

        function beforeDragOpen(treeId, treeNode) {
            //        autoExpandNode = treeNode;
            //        return true;
        }

        function beforeDrag(treeId, treeNodes) {
            //debugger
            //        for (var i = 0, l = treeNodes.length; i < l; i++) {
            //            if (treeNodes[i].drag === false) {
            //                return false;
            //            }
            //        }
            //        return true;
        }
        function beforeDrop(treeId, treeNodes, targetNode, moveType) {
            //debugger
            //return targetNode ? targetNode.drop !== false : true;
        }

        function dropPrev(treeId, nodes, targetNode) {
            //        var pNode = targetNode.getParentNode();
            //        if (pNode && pNode.dropInner === false) {
            //            return false;
            //        } else {
            //            for (var i = 0, l = curDragNodes.length; i < l; i++) {
            //                var curPNode = curDragNodes[i].getParentNode();
            //                if (curPNode && curPNode !== targetNode.getParentNode() && curPNode.childOuter === false) {
            //                    return false;
            //                }
            //            }
            //        }
            //        return true;
        }
        function dropInner(treeId, nodes, targetNode) {
            //        if (targetNode && targetNode.dropInner === false) {
            //            return false;
            //        } else {
            //            for (var i = 0, l = curDragNodes.length; i < l; i++) {
            //                if (!targetNode && curDragNodes[i].dropRoot === false) {
            //                    return false;
            //                } else if (curDragNodes[i].parentTId && curDragNodes[i].getParentNode() !== targetNode && curDragNodes[i].getParentNode().childOuter === false) {
            //                    return false;
            //                }
            //            }
            //        }
            //        return true;
        }
        function dropNext(treeId, nodes, targetNode) {
            //        var pNode = targetNode.getParentNode();
            //        if (pNode && pNode.dropInner === false) {
            //            return false;
            //        } else {
            //            for (var i = 0, l = curDragNodes.length; i < l; i++) {
            //                var curPNode = curDragNodes[i].getParentNode();
            //                if (curPNode && curPNode !== targetNode.getParentNode() && curPNode.childOuter === false) {
            //                    return false;
            //                }
            //            }
            //        }
            //        return true;
        }

        function onDrag(event, treeId, treeNodes) {
            ///className = (className === "dark" ? "" : "dark");
            ///showLog("[ " + getTime() + " onDrag ]&nbsp;&nbsp;&nbsp;&nbsp; drag: " + treeNodes.length + " nodes.");
        }
        function onDrop(event, treeId, treeNodes, targetNode, moveType, isCopy) {
            ///className = (className === "dark" ? "" : "dark");
            ///showLog("[ " + getTime() + " onDrop ]&nbsp;&nbsp;&nbsp;&nbsp; moveType:" + moveType);
            ///showLog("target: " + (targetNode ? targetNode.name : "root") + "  -- is " + (isCopy == null ? "cancel" : isCopy ? "copy" : "move"))
        }
        function onExpand(event, treeId, treeNode) {
            //        if (treeNode === autoExpandNode) {
            //            className = (className === "dark" ? "" : "dark");
            //            showLog("[ " + getTime() + " onExpand ]&nbsp;&nbsp;&nbsp;&nbsp;" + treeNode.name);
            //        }
        }

        $(document).ready(function () {
            $.get($("#tree1").attr("url"),
                function (d, t) {
                    var data = eval("(" + d + ")");
                    var _temp = [];
                    $.each(data, function (e) {
                        _temp.push($.extend(data[e], { drag: true }));
                    });
                    $.fn.zTree.init($("#tree1"), setting, _temp);
                });
        });

    </script>
<script src="../../Scripts/datagrid/list.common.button.js"  type="text/javascript"></script>
<script src="../../Scripts/common/jquery.action.js"  type="text/javascript"></script>
<script src="../../Scripts/ctrls/jquery.fixed.dialog.js" type="text/javascript"></script>
<script src="../../Scripts/ctrls/jquery.fixed.windows.js" type="text/javascript"></script>
<script src="../../Scripts/app/list/model.<% =EntityName %>.js" type="text/javascript"></script>
</body>
</html>
